﻿Shader "Level4/UV/Flow" {
	Properties {
		_MainTex ("Base (RGB)", 2D) = "white" {}
		_Color("Color",Color) = (1,1,1,1)
		
		_InterlaceMap("Interlace Map",2D) = ""{}
		_InterlaceMapTiling("Interlace Tiling",Vector) = (1,1,0,0)
		_InterlaceAmount("Interlace Amount",float) = 0.1
		_InterlaceColor("Color",Color) = (1,1,1,1)
	}
	CGINCLUDE
		#include "UnityCG.cginc"
		
		struct v2f{
			half4 pos:POSITION;
			half2 uv:TEXCOORD;
			half2 scrollUv:TEXCOORD1;
		};
		sampler _MainTex;
		half4 _Color;
		
		sampler _InterlaceMap;
		half4 _InterlaceMapTiling;
		half _InterlaceAmount;
		half4 _InterlaceColor;
		
		v2f vert(appdata_base i){
			v2f o;
			o.pos = mul(UNITY_MATRIX_MVP,i.vertex);
			o.uv = i.texcoord;
			o.scrollUv = i.texcoord.xy * _InterlaceMapTiling.xy + _InterlaceMapTiling.zw * _Time.xy;
			return o;
		}
		half4 frag(v2f i):COLOR{
			half4 c = tex2D(_MainTex,i.uv);
			half4 inter = tex2D(_InterlaceMap,i.scrollUv);
			
			return c * _Color + inter * _InterlaceColor * _InterlaceAmount;
		}
	ENDCG
	SubShader {
		Tags { "RenderType"="Opaque" }
		LOD 200
		Pass{
			// Blend SrcAlpha OneMinusSrcAlpha
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			ENDCG
		}
	} 
	FallBack "Diffuse"
}
